package com.keyinong.jiashiyuan.tools;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import android.content.Context;

public class HttpTools {
	Context context;
	AsyncHttpClient client=new AsyncHttpClient();
	
	public HttpTools(Context context) {
		super();
		this.context = context;
	}
	
	/**登录请求 */
	public void login(String username, String password,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("username", username);
		params.put("password", password);
		client.post(context, Tools.loginUrl, params, backcall);

	}
	/**商品信息请求*/
	public void Shangpin(String token, String orderid,JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		client.post(context, Tools.shangpinUrl, params, backcall);
	}
	
	/**订单信息请求*/
	public void Dingdan(String token,JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		client.post(context, Tools.dingdanUrl, params, backcall);
	}
	
	/**更新订单状态*/
	public void Refresh(String token,String state,String orderid ,JsonHttpResponseHandler backcall){
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		params.put("state", state);
		client.post(context, Tools.refreshUrl, params, backcall);
	}
}
